package com.gitee.chili.leisure.domain;

import com.gitee.chili.leisure.base.GenerateId;
import com.gitee.chili.leisure.enums.Status;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * Member
 *
 * @author week solider
 * @since 2020.09.01
 */
@Data
@Entity
@Accessors(chain = true)
@Table(name = "leisure_member")
@EqualsAndHashCode(callSuper = true)
public class Member extends GenerateId<Long> {

    private String username;

    private String nickname;

    private String password;

    /**
     * 头像
     */
    private String portrait;

    /**
     * 性别 默认男
     * 2:不详
     * 1:男
     * 0:女
     */
    private Integer gender;

    private String phone;

    /**
     * 状态
     * 1:启用
     * 0:禁用
     */
    private Status status;

    /**
     * 等级
     */
    private Integer level;

    /**
     * 经验
     */
    private BigDecimal exp;

    /**
     * 省份
     */
    @OneToOne
    @JoinColumn(name = "area_province")
    private Area areaProvince;

    /**
     * 城市
     */
    @OneToOne
    @JoinColumn(name = "area_city")
    private Area areaCity;

    /**
     * 玩家账户信息, 用于快速查询账户, 只可获取, 不用于更新等
     */
    @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, targetEntity = Account.class)
    @JoinColumn(name="member_id")
    private List<Account> accounts;

    public Member() {
    }
}
